package day15;

public class TestException {
	public static void main(String[] args) {
		try {
			m1();	
		} catch (DException e) {
			System.out.println("D");
		} catch (CException e) {
			System.out.println("C");
		} catch (BException e) {
			System.out.println("B");
		} catch (FException e) {
			System.out.println("F");
		} catch (AException e) {//o instanceof AException
			System.out.println("A");
		} catch (Exception e) {
			System.out.println("Exception");
		}
		try{
			m1();
		}catch(Exception e){//o instanceof Exception
			System.out.println("========Exception======");
		}
		try{
			m2();
		}catch(RuntimeException e){
			
		}
		try{
			m2();
		}finally{
			System.out.println("finally");
		}
	}

	public static void m1() throws Exception/* BException,FException,AException */{
		int i = 0;
		if (i == 0) {
			throw new BException();
		} else if (i == 1) {
			throw new CException();
		} else if (i == 2) {
			throw new DException();
		} else if (i == 3) {
			throw new FException();
		} else {
			throw new AException();
		}
	}
	public static void m2(){
		throw new RuntimeException();
	}
}

class AException extends Exception {
}

class BException extends AException {
}

class CException extends BException {
}

class DException extends BException {
}

class FException extends Exception {
}


class Parent{
	Object show()throws BException{
		return null;
	}
}
interface IA{
	void m() throws BException;
}
class Child extends Parent implements IA{
	Number show()throws CException{
		return null;
	}
	public void m()throws CException{
		
	}
}
